PREFIX     = %PREFIX%
MANDIR     = %MANDIR%
CC         = %CC%
RM         = %RM%

CFLAGS    = -DVERSION="\"0.1.2pre3\"" %DEFINES% %CFLAGS%
LDFLAGS   = %LDFLAGS%
LIBS      = %LIBS%

# for debugging
#CFLAGS    += -ggdb3
#CFLAGS    += -DDEBUG_EVENTS -DSYNC
#CFLAGS    += -Wall -Wextra -Wno-unused-parameter

OBJFILES  = actions.o buttons.o client.o config.o defcfg.o drag.o events.o evn.o ewmh.o info.o input.o main.o misc.o opcodes.o screens.o vdesk.o wlist.o x11.o

all: matwm2

matwm2: $(OBJFILES)
	$(CC) $(LDFLAGS) -o $@ $(OBJFILES) $(LIBS)

clean:
	$(RM) matwm2 *.o

install: matwm2
	mkdir -p $(PREFIX)/bin $(MANDIR)/man1
	install -s matwm2 $(PREFIX)/bin
	install matwm2.1 $(MANDIR)/man1

deinstall:
	$(RM) $(PREFIX)/bin/matwm2 $(MANDIR)/man1/matwm2.1* $(MANDIR)/cat1/matwm2.1*

# converts default_matwmrc into C code that can be compiled into the binary
defcfg:
	perl makedefcfg.pl

# generates all.h wich defines most global variables and functions
header:
	perl makeheader.pl
